#!/bin/bash

WORK_DIR=$(cd $(dirname $0); pwd)

mkdir -p ${WORK_DIR}/log

export ROS_LOG_DIR=${WORK_DIR}/log

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/ros/humble/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${WORK_DIR}/cartographer/install/lib

source /opt/ros/humble/setup.bash
source ${WORK_DIR}/cartographer_ros/install/setup.bash

DATASET=/home/reiko/codespace/dataset/b0-2014-07-21-12-49-19

rm -rf ${WORK_DIR}/log/*

operation=$1

if [ "$operation" == "local" ];then
    ros2 launch cartographer_ros demo_backpack_2d_localization.launch.py bag_filename:=${DATASET} load_state_filename:=${WORK_DIR}/assets/b0-2014-07-21-12-49-19.pbstream
else
    ros2 launch cartographer_ros demo_backpack_2d.launch.py bag_filename:=${DATASET}
fi

